<template>
  <div>
    <my-breadcrumb :items="['商户提现', '提现记录']"></my-breadcrumb>
    <Table :data="list" :columns="listCol"></Table>
    <page-info :page="page" @pageNumChange="pageNumChange" @pageSizeChange="pageSizeChange"></page-info>
  </div>
</template>

<script>
import pageInfo from '../../common/pageInfo'
export default {
  name: 'withdraw-list',
  data () {
    return {
      url: {
        list: '/withdrawal/order/list'
      },
      list: [],
      listCol: [
        {
          type: 'index',
          width: 50
        },
        {
          title: '提现账户名',
          key: 'withdrawalNickname'
        },
        {
          title: '提现金额',
          key: 'withdrawAmount',
          render: (h, params) => {
            return h('span', params.row.withdrawAmount / 100 + '￥')
          }
        },
        {
          title: '状态',
          key: 'status',
          render: (h, params) => {
            let type = ''
            let text = ''
            switch (params.row.status) {
              case 0:
                type = 'red'
                text = '未支付'
                break
              case 1:
                type = 'yellow'
                text = '处理中'
                break
              case 2:
                type = 'green'
                text = '支付成功'
                break
              case 3:
                type = 'red'
                text = '支付失败'
                break
            }
            return h('Tag', {
              props: {
                color: type
              }
            }, text)
          }
        },
        {
          title: '支付时间',
          key: 'paymentTime',
          render: (h, params) => {
            return h('span', new Date(params.row.paymentTime).toLocaleString())
          }
        }
      ],
      page: {
        pageNum: 1,
        pageSize: 10,
        total: 0
      }
    }
  },
  methods: {
    initList (page) {
      this.$ajax.post(this.url.list, {pageNum: page.pageNum, pageSize: page.pageSize})
        .then(res => {
          if (res.data.success) {
            this.page.total = res.data.data.total
            this.list = res.data.data.list
          }
        })
    },
    pageSizeChange (page) {
      this.initList(page)
    },
    pageNumChange (page) {
      this.initList(page)
    }
  },
  components: {
    pageInfo
  },
  created () {
    this.initList(this.page)
  }
}
</script>

<style scoped>

</style>
